package com.eureka.provider.validator;/*
 *@Description
 *@Author:Sam
 *@creat-time:2021/4/14 16:44
 */


import net.sf.jsqlparser.util.validation.ValidationUtil;
import org.apache.commons.lang.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class isMobileValidator implements ConstraintValidator<isMobile,String> {
    boolean required=false;
    @Override
    public void initialize(isMobile constraintAnnotation) {
        required=constraintAnnotation.required();
    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if(required){
            //正则匹配手机号校验
        }else{
            if(StringUtils.isEmpty(s)){
                return true;
            }else{
                //正则匹配手机号校验
            }
        }
        return false;
    }
}
